﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApplicationSecurityService
{
    class LogHelper : Singleton<LogHelper>
    {
        private String logFileName = "asLog.txt";  
        private String logFilePath;
        public void Init()
        {
            try
            {            
                // 获取程序运行位置
                String appFilePath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\";
                if (!Directory.Exists(appFilePath))
                {
                    Directory.CreateDirectory(appFilePath);
                }
                logFilePath = appFilePath + logFileName;
                WriteLog("App Path:" + appFilePath);
            }
            catch { }
        }

        public void WriteLog(String logMsg)
        {
            try
            {
                File.AppendAllText(logFilePath, logMsg + "\r\n");
            }
            catch { }
        }
    }
}
